package com.sk.bilibili.controller;

import com.sk.bilibili.bean.Image;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.ToolService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/12/4 14:35
 */
@CrossOrigin
@RestController
@RequestMapping("/tool")
@Api(tags = "小工具相关")
public class ToolController {

    @Autowired
    private ToolService toolService;

    @ApiOperation("上传图片  获取对应链接  只需要文件  info可以随便写一下")
    @PostMapping("/uploadRes")
    public R<List<Image>> uploadRes(MultipartFile[] files) {
        return toolService.uploadRes(files);
    }

    @ApiOperation("根据资源Id删除资源")
    @GetMapping("/deleteRes")
    public R<Void> deleteRes(Integer id) {
        return toolService.deleteRes(id);
    }

    @ApiOperation("获取所有资源信息")
    @GetMapping("/getAll")
    public R<List<Image>> getAll(){
        return toolService.getAll();
    }

}
